# -*- coding: utf-8 -*-
# @Time    : 19-4-4 下午6:29

import subprocess
from command import adb


def get_pid(package_name):
    command_pid = adb.get_memory + " | grep " + package_name
    ps_pid = subprocess.Popen(command_pid, stdout=subprocess.PIPE, shell=True)
    content_pid = ps_pid.communicate()[0]
    pid_list = (str(content_pid).split("\r\n"))[0].split(' ')
    pid_list = [x for x in pid_list if x != '']
    pid_num = pid_list[4].split(')')[0]
    return str(pid_num)
